<?php
/* 
 * akimimi front
 * 
 * Add Delivery
 * 
 * @author steve
 * 
 */
require_once '../app/views/BaseView.php';

class DeliveryView extends BaseView {
	public function getPage($deliveryLists){
		$this->setPageTitle(constant("RECEIVEADDRESS"));
		$this->addJS('frontend.js',true);
		$this->addCSS('myaccountleftnav.css');
		$this->addCSS('myaccount.css');
		$header = '';
		$str_result = $header
                    . $this->getContent($deliveryLists);
        return $this->getHtmlPage($str_result);
	}
	
	public function getContent($deliveryLists){
		$str_hidden = '<input type="hidden" id="errorAreaEmpty" value="'.ERRORAREA.'" /><input type="hidden" id="errorReceiverNameEmpty" value="'.RECEIVERNAMEEMPTY.'" />';
	    $str_hidden .= '<input type="hidden" id="errorDetailAddressEmpty" value="'.DETAILADDRESSEMPTY.'" /><input type="hidden" id="errorMobileEmpty" value="'.MOBILEEMPTY.'" />';
	    $str_hidden .= '<input type="hidden" id="errorMobileError" value="'.MOBILEERROR.'" /><input type="hidden" id="errorEmailBoxEmpty" value="'.EMAILBOXEMAPTY.'" />';
	    $str_hidden .= '<input type="hidden" id="errorEmailBoxError" value="'.EMAILBOXERROR.'" /><input type="hidden" id="confirmInfo" value="'.DELCONFIRM.'" />';
	    
	    $str_result = '<div id="navigation"><a href="/">'.WEBSITEINDEXPAGETXT.'</a><span>></span><a href="/userinfo/index">'.MYAKIMIMITXT.'</a><span>></span><a href="/userinfo/delivery">'.MYDELIVERYADDR.'</a></div>';
	    $str_result .= $str_hidden;
	    $str_result .= '<div id="mymimi_body">'.MyAccountLeftNav::getMyAccountLeftNav();
	    $str_result .= '<div id="mymimi_right"><div class="right_bj"></div>';
	    if(count($deliveryLists[0])<5){
	        $str_result .= '<div class="add_button"><p><img src="'.ConfigConstants::getTImagePath().'/add_001.jpg" alt="" style="cursor:pointer;" onclick="javascript:Delivery.addDeliveryAddr();" /></p></div>';
	    }
	    if($deliveryLists){
	        $str_result .= DeliveryListView::getDeliveryList($deliveryLists);
	    }
	    
	        $str_result .= '<div class="add_border" style="display:none;" id="deliveryInfoList">';
	        $str_result .= '<form action="/o/delivery" method="post" id="deliveryForm" onsubmit="javascript:return Delivery.deliverySubmit();">';
	        $str_result .= '<input type="hidden" id="deliveryId" name="deliveryId" value="0" />';
	        $str_result .= '<div class="add_row_1" style="margin-top:10px;"><ul>';
	        $str_result .= '<li class="style_1">'.RECEIVENAME.'</li><li class="style_2"><input type="text" class="input_delivery" id="receiverName" name="receiverName" onblur="javascript:Delivery.validateReceiverName();"/></li>';
            $str_result .= '<li class="style_star">*</li><li><span id="errorReceiverName" class="error_font_color" ></span></li>';
	        $str_result .= '</ul></div>';
	        $str_result .= '<div class="add_row_1"><ul>';
	        $str_result .= '<li class="style_1">'.AREADICT.'</li><li class="style_2">'.CommonUtil::getCityDictHtml().'</li>';
            $str_result .= '<li><span id="errorAreaDict" class="error_font_color" style="margin-left:120px;" ></span></li>';
            $str_result .= '</ul></div>';
            $str_result .= '<div class="add_row_1"><ul><li class="style_1">'.DETAILADDRESS.'</li>';
            $str_result .= '<li class="style_addr"><textarea name="detailAddress" id="detailAddress" class="text_style" rows="4" cols="300"  onblur="javascript:Delivery.validateDetailAddress();" ></textarea></li>';
            $str_result .= '<li class="style_star" style="width:20px;">*</li><li><span id="errorDetailAddress" class="error_font_color" ></span></li>';
            $str_result .= '</ul></div>';
            $str_result .= '<div class="add_row_1"><ul>';
            $str_result .= '<li class="style_1">'.TELEPHONE.'</li><li class="style_2"><input type="text" class="input_delivery" id="phone" name="phone"/></li>';
            $str_result .= '<li class="style_star"></li><li><span id="errorPhone" class="error_font_color" ></span></li>';
            $str_result .= '</ul></div>';
            $str_result .= '<div class="add_row_1"><ul>';
            $str_result .= '<li class="style_1">'.MOBILE.'</li><li class="style_2"><input type="text" class="input_delivery" id="mobile" name="mobile" onblur="javascript:Delivery.validateMobile();"/></li>';
	        $str_result .= '<li class="style_star">*</li><li><span id="errorMobile" class="error_font_color" ></span></li>';
	        $str_result .= '</ul></div>';
	        $str_result .= '<div class="add_row_1"><ul>';
	        $str_result .= '<li class="style_1">'.EMAILBOX.'</li><li class="style_2"><input type="text" class="input_delivery" id="email" name="email" onblur="javascript:Delivery.validateEmail();"/></li>';
	        $str_result .= '<li class="style_star">*</li><li><span id="errorEmail" class="error_font_color" ></span></li>';
	        $str_result .= '</ul></div>';
	        $str_result .= '<div class="add_row_2">';
			$str_result .= '<div class="button1" style="cursor:pointer;" onclick="javascript:Delivery.deliverySubmit();">'.SAVEBTN.'</div>';
            $str_result .= '<div class="button1" style="cursor:pointer;" onclick="javascript:Delivery.cancelDeliveryAddr();" >'.CANCELBTN.'</div>';
            $str_result .= '</div>';
            $str_result .= '</form></div>';
	    
	    
	    $str_result .= '</div></div>';
	    
	    return $str_result;
	
	}
}
